package com.myschool.server.model;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "user_tbl")
public class User extends BaseEntity {

	@Column(name = "openid_provider", length = 20, nullable = true)
	private String openIdProvider;

	@Column(name = "reg_status", length = 2, nullable = false)
	@Enumerated(EnumType.STRING)
	private RegistrationStatus registrationStatus;

	@Column(name = "user_name", length = 25, nullable = false)
	private String username;

	@Column(name = "password", length = 25, nullable = true)
	private String password;

	@Column(name = "first_name", length = 100, nullable = false)
	private String firstName;

	@Column(name = "middle_name", length = 100)
	private String middleName;

	@Column(name = "last_name", length = 100)
	private String lastName;

	@Column(length = 15, nullable = true)
	@Enumerated(EnumType.STRING)
	private UserType type;

	@Column(name = "phone_Number", length = 12, nullable = true)
	private String phoneNumber;

	@Column(name = "email_Address", length = 25, nullable = true)
	private String emailAddress;

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Address address;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private List<Skill> skills;

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private School school;

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Section section;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<Role> roles;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<HomeWork> homeWork;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<Attendance> attendance;

	/**
	 * @return the school
	 */
	public School getSchool() {
		return school;
	}

	/**
	 * @param school
	 *            the school to set
	 */
	public void setSchool(School school) {
		this.school = school;
	}

	/**
	 * @return the section
	 */
	public Section getSection() {
		return section;
	}

	/**
	 * @param section
	 *            the section to set
	 */
	public void setSection(Section section) {
		this.section = section;
	}

	/**
	 * @return the homeWork
	 */
	public Set<HomeWork> getHomeWork() {
		return homeWork;
	}

	/**
	 * @param homeWork
	 *            the homeWork to set
	 */
	public void setHomeWork(Set<HomeWork> homeWork) {
		this.homeWork = homeWork;
	}

	/**
	 * @return the attendance
	 */
	public Set<Attendance> getAttendance() {
		return attendance;
	}

	/**
	 * @param attendance
	 *            the attendance to set
	 */
	public void setAttendance(Set<Attendance> attendance) {
		this.attendance = attendance;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getMiddleName() {
		return middleName;
	}

	public void setMiddleName(String middleName) {
		this.middleName = middleName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	/**
	 * @param skills
	 *            the skills to set
	 */
	public void setSkills(List<Skill> skills) {
		this.skills = skills;
	}

	/**
	 * @return the skills
	 */
	public List<Skill> getSkills() {
		return skills;
	}

	/**
	 * @return the roles
	 */
	public Set<Role> getRoles() {
		return roles;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @param roles
	 *            the roles to set
	 */
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	/**
	 * @return the openIdProvider
	 */
	public String getOpenIdProvider() {
		return openIdProvider;
	}

	/**
	 * @param openIdProvider
	 *            the openIdProvider to set
	 */
	public void setOpenIdProvider(String openIdProvider) {
		this.openIdProvider = openIdProvider;
	}

	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username
	 *            the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the registrationStatus
	 */
	public RegistrationStatus getRegistrationStatus() {
		return registrationStatus;
	}

	/**
	 * @param registrationStatus
	 *            the registrationStatus to set
	 */
	public void setRegistrationStatus(RegistrationStatus registrationStatus) {
		this.registrationStatus = registrationStatus;
	}

	/**
	 * @return the type
	 */
	public UserType getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(UserType type) {
		this.type = type;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

}
